/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pagrafo.teste;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import pagrafo.arquivo.Arquivo;
import pagrafo.genetico.AlgoritmoGenetico;
import pagrafo.genetico.Cromossomo;
import pagrafo.genetico.Populacao;
import pagrafo.grafo.Grafo;

/**
 *
 * @author Fabricio
 */
public class TesteGrafoAG {
    
    public static void main(String[] args) throws FileNotFoundException, IOException {
        int k = 10;
        Arquivo a = new Arquivo("A-n80-k10.vrp");
        Grafo g = a.getG();
        double capacidade = a.getCapacidade();
        
        AlgoritmoGenetico ag;
        ArrayList<Cromossomo> solucoesLocais = new ArrayList<Cromossomo>();
        
        for (int i = 0; i < 100; i++){
            System.out.println("Execução do AG: " + (i+1));
            ag = new AlgoritmoGenetico(g, k, capacidade, 50, 200); 
            ag.executar();
            solucoesLocais.add(ag.getCromossomos().get(0));
        }
        
        Collections.sort(solucoesLocais);
        
        System.out.println("###################################################");
        System.out.println("                 SOLUÇÕES LOCAIS");
        System.out.println("###################################################");
        Populacao.imprimePopulacao(solucoesLocais);
        System.out.println("###################################################");
        
        ag = new AlgoritmoGenetico(g, k, capacidade, 50, 1000, solucoesLocais);
        ag.executar();
        System.out.println("###################################################");
        System.out.println("                 SOLUÇÕES GLOBAIS");
        System.out.println("###################################################");
        Populacao.imprimePopulacao(ag.getCromossomos());
        
                     
    }
    
}
